import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class VendingMachineItemTest {
	VendingMachineItem itm1;

	@Before
	public void setUp() throws Exception {
		itm1 = new VendingMachineItem("Coke", 1.50);
	}

	@After
	public void TearDown() throws Exception {
		itm1 = null;
	}

	@Test
	public void testVendingMachineItem() {
		assertEquals(1.50, itm1.getPrice(), 0);
	}

	@Test
	public void testVendingMachineItem_ValidPrice() {
		VendingMachineItem vnd1 = new VendingMachineItem("Doritos", 1.0);
		assertEquals("Doritos", vnd1.getName());
		assertEquals(1.0, vnd1.getPrice(), 0);
	}

	@Test
	public void testVendingMachineItem_ZeroPrice() {
		VendingMachineItem vnd1 = new VendingMachineItem("Doritos", 0.0);
		assertEquals("Doritos", vnd1.getName());
		assertEquals(0.0, vnd1.getPrice(), 0);
	}

	@Test(expected = VendingMachineException.class)
	public void testVendingMachineItem_Negative() {
		VendingMachineItem vnd1 = new VendingMachineItem("Doritos", -1.0);
	}

	@Test
	public void testGetName() {
		assertEquals("Coke", itm1.getName());
	}

	@Test
	public void testGetPrice() {
		assertEquals(1.50, itm1.getPrice(), 0);
	}

}
